org.mentalsmash.asksusanna.SusyConf = function(options){
	
	options = options || {};
	options.minLength = options.minLength || 2;
	options.maxScores = options.minScores || [0,10,20,50,100,100,100];
	options.minScores = options.minScores || [0,-200,-100,-50,0,0,0];
	
	var maxScores = options.maxScores;
	var minScores = options.minScores;
	var minLength = options.minLength;
	
	var scoringFunctionParameters = [
		{},
		{},
		{
			scores : {
				min : -100,
				max : 50
			},
			hits : {
				score0 : 100,
				max : 1000
			}
		},
		{
			scores : {
				min : -50
			},
			hits : {
				score0 : 50,
				max : 100
			}
		},
		{
			hits : {
				max : 10
			}
		},
		{
			hits : {
				max : 5
			}
		},
	
	];
	
	var scoringFunction = function(parameters) {
		parameters = parameters || {};
		parameters.scores = parameters.scores || {};
		parameters.scores.min = parameters.scores.min || 0;
		parameters.scores.max = parameters.scores.max || 100;
		parameters.hits = parameters.hits || {};
		parameters.hits.min = parameters.hits.min || 0;
		parameters.hits.score0 = parameters.hits.score0 || 0;
		parameters.hits.max = parameters.hits.max || 100;
		
		var scores = parameters.scores;
		var hits = parameters.hits;
		
		var lineBetweenPoints = function(p1,p2) {
			
			if (p1[1] === p2[1] || p1[0] === p2[0]) {
				return function() {
					return p1[1];
				}
			} else {
				return function(x) {
					var y = x - p1[0];
					y = y * (p2[1] - p1[1]);
					y = y / (p2[0] - p1[0]);
					y = y + p1[1];
					return y;
				}
			}
		};
		
		return function(x) {
			var scoringfunc = {};
			
			if (hits.min <= x && x <= hits.score0) {
				var p1 = [hits.min,scores.min];
				var p2 = [hits.score0,0];
				scoringfunc = lineBetweenPoints(p1,p2);
			} else if ( hits.score0 < x && x < hits.max) {
				var p1 = [hits.score0,0];
				var p2 = [hits.max,scores.max];
				scoringfunc = lineBetweenPoints(p1,p2);
			} else if (x > hits.max) {
				scoringfunc = function(){
					return scores.max;
				}
			} else {
				scoringfunc = function(){
					return scores.min;
				}
			}
			
			return scoringfunc(x);
		}
		
	}
	
	return {
		'getScoringFunction' : function(len) {
			if (len >= scoringFunctionParameters.length) {
				len = scoringFunctionParameters.length - 1;
			}
			return scoringFunction(scoringFunctionParameters[len]);
		},

		'getMaxScore' : function(len) {
			if (len >= scoringFunctionParameters.length) {
				len = scoringFunctionParameters.length - 1;
			}
			
			if (len <= 1) {
				return 0;
			}
			return scoringFunctionParameters[len].scores.max;
		},

		'getMinScore' : function(len) {
			if (len >= scoringFunctionParameters.length) {
				len = scoringFunctionParameters.length - 1;
			}
			
			if (len <= 1) {
				return 0;
			}
			return scoringFunctionParameters[len].scores.min;
		},
		
		'getMinLength' : function(){
			return minLength;
		},
		
		'getPhraseParameters' : function(ph) {
			var len = ph.words().length;
			if (len >= scoringFunctionParameters.length) {
				len = scoringFunctionParameters.length - 1;
			}
			return scoringFunctionParameters[len];
		},
		
		'setPhraseParameters' : function(len,par) {
			scoringFunctionParameters[len] = par;
		}
	};
}